local skel = fk.CreateSkill{
  name = "kt_ls__hufu",
}

Fk:loadTranslationTable{
  ["kt_ls__hufu"] = "狐抚",
  [":kt_ls__hufu"] = "当一名角色使用牌时，若其体力值为1/2，且没有角色处于濒死状态，你可以重铸一张同花色的牌，令之当【决斗】/【杀】结算。",
  ["#kt_ls__hufu"] = "狐抚：你可以重铸一张 %arg 牌，令 %arg2 当【%arg3】结算",

  ["$kt_ls__hufu1"] = "万俟在左，张俊在右，且叫他束手，引颈以候。",
  ["$kt_ls__hufu2"] = "一令出不为，三令至不尊，十二令，则当死！",
}

skel:addEffect(fk.CardUsing,{
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(skel.name) and not player:isNude() and
    (data.from.hp == 1 or data.from.hp == 2) and (data.card.type == Card.TypeBasic or data.card:isCommonTrick()) and
      not table.find(player.room:getAlivePlayers(), function(p)
        return p.dying
      end)
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local c = data.card
    local cc = data.from.hp == 1 and "duel" or "slash"
    local _,card = room:askToChooseCardsAndPlayers(player,{
      prompt = "#kt_ls__hufu:::".. c:getSuitString() ..":".. c.name ..":".. cc,
      min_card_num = 1,
      max_card_num = 1,
      min_num = 0,
      max_num = 0,
      targets = {},
      skill_name = skel.name,
      pattern = ".|.|"..c:getSuitString(),
      cancelable = true,
    })
    if #card > 0 then
      event:setCostData(self,{card = card})
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    --重铸
    local card = event:getCostData(self).card
    room:recastCard(card,player,skel.name)
    --改效果
    if #data.tos > 0 then
      local cc = data.from.hp == 1 and "duel" or "slash"
      data:changeCard(cc,data.card.suit,data.card.number)
    else
      data.toCard = nil
      data:removeAllTargets()
    end
  end,
})

return skel